package com.chen.results;

import com.chen.constant.ResultConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;
    private ResultBody<T> resultBody;


    public static <T> Result<T> successLogin(T data, String jwt) {
        return new Result<T>(ResultConstant.CODE_SUCCESS, ResultBody.successLogin(data, jwt));
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(ResultConstant.CODE_SUCCESS, ResultBody.success(data));
    }
  public static <T> Result<T> success() {
        return new Result<T>(ResultConstant.CODE_SUCCESS, ResultBody.success());
    }

    public static <T> Result<T> error(Integer code, String msg) {
        return new Result<T>(code, ResultBody.error(msg));
    }


}
